<%@ tag language="java" pageEncoding="UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<%@ attribute name="id" type="java.lang.String" required="true" description="编号" %>
<%@ attribute name="name" type="java.lang.String" required="true" description="隐藏域名称（ID）" %>
<%@ attribute name="value" type="java.lang.String" required="true" description="隐藏域值（ID）" %>
<%@ attribute name="labelName" type="java.lang.String" required="true" description="输入框名称（Name）" %>
<%@ attribute name="labelValue" type="java.lang.String" required="true" description="输入框值（Name）" %>
<%@ attribute name="title" type="java.lang.String" required="true" description="选择框标题" %>
<%@ attribute name="labelUrl" type="java.lang.String" required="true" description="要提交的url" %>
<input id="${id}Id" name="${name}" class="${cssClass}" type="hidden" value="${value}"/>
<a id="${id}Button" name="${labelName}" labelUrl="" value="${labelValue}"
   style="cursor: pointer">${labelName}</a><%--<a id="${id}Button" href="javascript:" class="btn ${disabled} ${hideBtn ? 'hide' : ''}"
                                  style="${smallBtn?'padding:4px 2px;':''}">&nbsp;<i class="icon-search"></i>&nbsp;</a>&nbsp;&nbsp;--%>
<script type="text/javascript">
    $("#${id}Button, #${id}Name").click(function () {
        // 正常打开 /task/tsAdvertTaskRecord
        top.$.jBox.open("iframe:${ctx}${labelUrl}", "选择${title}", 900, 400, {
            ajaxData: {advertTaskId: $("#${id}Id").val(), id: $("#${id}Id").val(), flag: ""},
            buttons: {"确定": "ok", ${allowClear?"\"清除\":\"clear\", ":""}"关闭": true},
            submit: function (v, h, f) {
                if (v == "ok") {
                    var tree = h.find("iframe")[0].contentWindow.confiom();//h.find("iframe").contents();
                    if (tree == false) {
                        top.$.jBox.tip("必须选择一个人员。");
                        return false;
                    } else {
                        var s = tree.split("|");
                        $("#${id}Id").val(s[0]);
                        $("#${id}Name").val(s[1]);
                    }

                }//<c:if test="${allowClear}">
                else if (v == "clear") {
                    $("#${id}Id").val("");
                    $("#${id}Name").val("");
                }//</c:if>
                if (typeof ${id}TreeselectCallBack == 'function') {
                    ${id}TreeselectCallBack(v, h, f);
                }
            },
            loaded: function (h) {
                $(".jbox-content", top.document).css("overflow-y", "hidden");
            }
        });
    });
</script>